<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function dog(name, sex) {
        let obj = {};
        obj.name = name;
        obj.sex = sex;
        obj.hook = function () {
          console.log(name, "汪汪汪");
        };
        return obj;
      }
      var dog1 = dog("大豪", "公狗");
      var dog2 = dog("77", "漂亮狗");
      var dog3 = dog("小丁", "公狗");
      dog2.hook = () =>
        setInterval(() => {
          console.log(dog2.name, "汪汪汪");
        }, 1000);
      dog1.hook();
      dog2.hook();
      dog3.hook();
    </script>
  </body>
</html>
